#include<iostream>
#include "RBTree.h"
//#include "addBST.h"

int main() {
    rbtree  tree;

    int     method;
    int     number;
    int		i=0;

    while( i<200 ) {
        i++;
		cout << " \n\n 0: Exit\n 1: Insert\n 2: Delete\n 3: Inorder\n 4: Display\n 5: Member\n 6: Rank\n 7:Select\n";
        cout << "input type: ";
        cin >> method;

        switch( method ) {
            case 0:
                break;
            case 1:
                cout << "input insert number!: ";
                cin >> number;
                tree.insert( number );
                break;
            case 2:
                cout << "input delete number!: ";
                cin >> number;
                tree.remove( number );
                break;
            case 3:
                cout << "display inorder: \n";
                tree.inorder();
                break;
            case 4:
                cout << "display tree: \n";
                tree.echo();
                break;
            case 5:
                cout << "input search number!: ";
                cin >> number;
                cout << tree.search( number ) << "\n";
                break;

            case 6:
                cout << "input select number!: ";
                cin >> number;
                cout << tree.rank( tree.place(number) ) << "\n";
                break;
			case 7:
				cout << "input rank number!: ";
				cin >> number;
				cout << tree.select(number)->key << "\n";
				break;
            default:
                break;
        }
        
        if( method == 0 ) {
            break;
        }
    }


    return 0;
}

